package com.design.proxy.dynamicproxy.advanced1.mq2.listener;

import com.design.proxy.dynamicproxy.advanced1.mq2.BaseConsumer;
import com.design.proxy.dynamicproxy.advanced1.mq2.BaseConsumerProxy;
import com.design.proxy.dynamicproxy.advanced1.mq2.MsgLogServiceImpl;
import com.design.proxy.dynamicproxy.advanced1.mq2.consumer.LoginLogConsumer;

import java.io.IOException;

public class LoginLogListener {
    public static void main(String[] args) throws IOException {
        LoginLogConsumer loginLogConsumer = new LoginLogConsumer();
        MsgLogServiceImpl msgLogService = new MsgLogServiceImpl();

        BaseConsumerProxy baseConsumerProxy = new BaseConsumerProxy(loginLogConsumer, msgLogService);
        BaseConsumer proxy = (BaseConsumer) baseConsumerProxy.getProxy();
        if (null != proxy) {
            String s1 = "s1";
            String s2 = "s2";
            proxy.consume(s1, s2);
        }
    }

    public void consume(String s1, String s2) throws IOException {
        LoginLogConsumer loginLogConsumer = new LoginLogConsumer();
        MsgLogServiceImpl msgLogService = new MsgLogServiceImpl();

        BaseConsumerProxy baseConsumerProxy = new BaseConsumerProxy(loginLogConsumer, msgLogService);
        BaseConsumer proxy = (BaseConsumer) baseConsumerProxy.getProxy();
        if (null != proxy) {
            proxy.consume(s1, s2);
        }
    }

}
